//
//  AreaDropDownCell.m
//  PigMarket
//
//  Created by mac on 2019/3/28.
//  Copyright © 2019 felix.pigmarket.oc. All rights reserved.
//

#import "AreaDropDownCell.h"

@interface AreaDropDownCell ()
/**
 leftTitle
 */
@property (nonatomic , strong) UILabel *leftTitle;

@end

@implementation AreaDropDownCell

+ (instancetype)cellWithTableView:(UITableView *)tableView {
    static NSString *identifierID = @"identifierID";
    AreaDropDownCell *cell = [tableView dequeueReusableCellWithIdentifier:identifierID];
    if (cell == nil) {
        cell = [[AreaDropDownCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:identifierID];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self initView];
        [self initLayout];
    }
    return self;
}

- (void)initView {
    // 添加子控件
    [self.contentView addSubview:self.leftTitle];
    [self.contentView addSubview:self.selectImgView];
}

- (void)initLayout {
    // 布局子控件
    [self.leftTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(20);
        make.centerY.mas_equalTo(self.contentView.mas_centerY);
        make.height.mas_equalTo(22);
    }];
    [self.selectImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-30);
        make.centerY.mas_equalTo(self.contentView.mas_centerY);
        make.size.mas_equalTo(CGSizeMake(18, 18));
    }];
}

#pragma mark - getter and setter
- (void)setModel:(SelectTribes *)model {
    _model = model;
    if ([JTool iSNull:model.tribeName]) {
        self.leftTitle.text = model.regionName;
    }else {
        self.leftTitle.text = model.tribeName;
    }
}

- (UILabel *)leftTitle {
    if (!_leftTitle) {
        _leftTitle = [[UILabel alloc] init];
        _leftTitle.textColor = [UIColor textBlackColor];
        _leftTitle.font = [UIFont middleFont];
    }
    return _leftTitle;
}
- (UIImageView *)selectImgView {
    if (!_selectImgView) {
        _selectImgView = [[UIImageView alloc] init];
    }
    return _selectImgView;
}
@end
